package com.ruoyi.back.controller

import com.ruoyi.app.common.Data
import com.ruoyi.app.common.PageData
import com.ruoyi.app.common.pageInfo
import com.ruoyi.back.domain.dto.UserMemberOrderSearchDto
import com.ruoyi.back.domain.vo.UserMemberOrderDetailVo
import com.ruoyi.back.domain.vo.UserMemberOrderListVo
import com.ruoyi.back.service.UserMemberOrderService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiImplicitParam
import io.swagger.annotations.ApiImplicitParams
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("system/userMemberOrder")
@Api(tags = ["订单管理"])
class UserMemberOrderController {

    @Autowired
    private lateinit var userMemberOrderService: UserMemberOrderService


    @ApiOperation("用户会员订单列表")
    @GetMapping("list")
    fun userMemberOrderPage(userMemberOrderSearchDto: UserMemberOrderSearchDto): PageData<UserMemberOrderListVo> = userMemberOrderService.userMemberOrderPage(userMemberOrderSearchDto).pageInfo()

    @ApiOperation("用户订单详情")
    @ApiImplicitParams(
        ApiImplicitParam(name = "orderId", value = "订单id", type = "path", required = true)
    )
    @GetMapping("get/{orderId}")
    fun userMemberOrderDetail(@PathVariable orderId: Long): Data<UserMemberOrderDetailVo> = userMemberOrderService.userMemberOrderDetail(orderId)


    @ApiOperation("移除会员订单")

    @ApiImplicitParams(
        ApiImplicitParam(name = "orderId", value = "订单id", type = "path", required = true)
    )
    @GetMapping("remove/{orderId}")
    fun removeMemberOrder(@PathVariable orderId: Long): Data<Boolean> = userMemberOrderService.removeMemberOrder(orderId)
}